package cn.maxhou.t0004;

import cn.maxhou.t0004.impl.newsDaoMySqlImppl;
import cn.maxhou.t0004.impl.newsDaoOracleImppl;
import cn.maxhou.t0004.impl.newsDaoRedisImppl;
import cn.maxhou.tongyon.dao.NewsDao;

public class SimpleDaoFactory {
    /**
     * 创建NewsDao实例的工厂方法
     */
    public static NewsDao getInstance(String key){
        //return new NewsDaoImpl();
        switch (key){
            case "mysql":
                return new newsDaoMySqlImppl();
            case "oracle":
                return new newsDaoOracleImppl();
            case "redis":
                return new newsDaoRedisImppl();
            default:
                    throw new RuntimeException("无效的数据库类型: " + key+",Dao获取失败");
        }
    }
}
